package com.surenpi.jenkins.client.view;

import com.surenpi.jenkins.client.BaseManager;
import com.surenpi.jenkins.client.folder.FolderJob;
import com.surenpi.jenkins.client.util.EncodingUtils;
import com.surenpi.jenkins.client.util.UrlUtils;
import java.io.IOException;

public class Views extends BaseManager {
   public void create(FolderJob folderJob, String viewName, String viewXml, Boolean crumbFlag) throws IOException {
      String path = UrlUtils.toBaseUrl(folderJob) + "createView?name=" + EncodingUtils.encodeParam(viewName);
      this.getClient().postXml(path, viewXml, crumbFlag);
   }

   public void create(String viewName, String viewXml, Boolean crumbFlag) throws IOException {
      this.create((FolderJob)null, viewName, viewXml, crumbFlag);
   }

   public void create(String viewName, String viewXml) throws IOException {
      this.create(viewName, viewXml, this.isCrumb());
   }

   public void update(FolderJob folder, String viewName, String viewXml, boolean crumbFlag) throws IOException {
      String path = UrlUtils.toBaseUrl(folder) + "view/" + EncodingUtils.encode(viewName) + "/getXml.xml";
      this.getClient().postXml(path, viewXml, crumbFlag);
   }

   public void update(String viewName, String viewXml, boolean crumbFlag) throws IOException {
      this.update((FolderJob)null, viewName, viewXml, crumbFlag);
   }

   public void update(String viewName, String viewXml) throws IOException {
      this.update(viewName, viewXml, this.isCrumb());
   }

   public View info(String viewName) throws IOException {
      return (View)this.getClient().get("/view/" + EncodingUtils.encode(viewName), View.class);
   }

   public String getXml(String viewName) throws IOException {
      return this.getClient().get("/view/" + EncodingUtils.encode(viewName) + "/getXml.xml");
   }

   protected String[] getDependencyArray() {
      return null;
   }
}
